#ifndef REQUEST_H
#define REQUEST_H

#include <QObject>
#include <QNetworkReply>
#include <QNetworkAccessManager>

struct Result
{
    int code;
    QString token;
    QString message;
};

class Request : public QObject
{
    Q_OBJECT
public:
    struct Result result;
    static Request *ptrRequest;
    static Request *getinstance()
    {
        if(nullptr == ptrRequest)
        {
            ptrRequest = new Request;
        }
        return ptrRequest;
    }

    explicit Request(QObject *parent = nullptr);

    QNetworkAccessManager *accessManager;
    QNetworkRequest request;
    QByteArray postData;
    QNetworkReply* reply;
    uint code;

    void init();//初始化

    void LoginByPassword(QString userName,QString pwd);//发送登录请求


    //void DishRecommendRequest(QString token);//发送菜谱推荐请求

private slots:
    void finishedSlot(QNetworkReply *reply);


signals:
    //void sendSuccess(QString url);
    void sendLoginByPasswordSuccess();
    //void sendDishRecommendSuccess();
};

#endif // REQUEST_H
